<template>



    <template v-for="item in menusdata" :key="item.id">
        <!-- 二级菜单 -->
        <el-sub-menu v-if="item.children" :index="item.path">
            <template #title>
                <el-icon v-if="item.icon">
                    <component :is="icons[item.icon]"></component>
                </el-icon>
                <span>{{ item.title }}</span>
            </template>
            <!-- (icons as any)[item.icon] -->
            <!-- 组件自己渲染自己 -->
            <SideMenu2 :menusdata="item.children" />


        </el-sub-menu>

        <!-- 一级菜单 -->
        <el-menu-item v-else :index="item.path">
            <el-icon v-if="item.icon">
                <component :is="icons[item.icon]"></component>
            </el-icon>
            <span>{{ item.title }}</span>
        </el-menu-item>
    </template>



</template>


<script setup lang="ts">

import * as icons from '@element-plus/icons-vue';
defineProps<{
    menusdata: menuitem[]
}>()
</script>

<style scoped></style>